package me.minecraft.plugin.pokemontip;

import com.cobblemon.mod.common.pokemon.Pokemon;

import java.util.Objects;

/**
 * @author langle__
 * @version 1.0
 */
public record PokemonType(String name, int id) {

    public static PokemonType normal;
    public static PokemonType shiny_normal;
    public static PokemonType mythical;
    public static PokemonType shiny_mythical;
    public static PokemonType ultra_beast;
    public static PokemonType shiny_ultra_beast;
    public static PokemonType legendary;
    public static PokemonType shiny_legendary;
    public static PokemonType paradox;
    public static PokemonType shiny_paradox;

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        PokemonType that = (PokemonType) object;
        return id == that.id;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    public static PokemonType getPokemonType(Pokemon pokemon) {
        if (pokemon.isLegendary()) {
            return pokemon.getShiny() ? shiny_legendary : legendary;
        } else if (pokemon.isUltraBeast()) {
            return pokemon.getShiny() ? shiny_ultra_beast : ultra_beast;
        } else if (pokemon.isMythical()) {
            return pokemon.getShiny() ? shiny_mythical : mythical;
        } else if (pokemon.hasLabels("paradox")) {
            return pokemon.getShiny() ? shiny_paradox : paradox;
        }

        return pokemon.getShiny() ? shiny_normal : normal;
    }

}
